package com.demo.gateway.utils;

/**
 * @author yzy
 * @date 2024/7/13 下午6:20
 */
public class AssembleTest {
    public static void main(String[] args) {
        String jsonRequest = "{\n" +
                "    \"type\": \"X\",\n" +
                "    \"scene\": 1,\n" +
                "    \"receiverAccountData\": [\n" +
                "        {\n" +
                "            \"type\": 2,\n" +
                "            \"merchantCode\": \"MXXXXX\",\n" +
                "            \"userCode\": \"UXXXXX\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"type\": 2,\n" +
                "            \"merchantCode\": \"MXXXXX\",\n" +
                "            \"userCode\": \"UXXXXX\"\n" +
                "        }\n" +
                "    ],\n" +
                "    \"paramData\": {\n" +
                "        \"key\": \"KEY_PLACEHOLDER\"\n" +
                "    },\n" +
                "    \"extAttr\": {\n" +
                "        \"beginTime\": \"2024-07-08 15:59:14\",\n" +
                "        \"mustFinish\": false,\n" +
                "        \"status\": 1\n" +
                "    }\n" +
                "}\n";
        String request = "{\n" +
                "    \"type\": \"X\",\n" +
                "    \"scene\": 1,\n" +
                "    \"receiverAccountData\": [\n" +
                "        {\n" +
                "            \"type\": 2,\n" +
                "            \"merchantCode\": \"MXXXXX\",\n" +
                "            \"userCode\": \"UXXXXX\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"type\": 2,\n" +
                "            \"merchantCode\": \"MXXXXX\",\n" +
                "            \"userCode\": \"UXXXXX\"\n" +
                "        }\n" +
                "    ],\n" +
                "    \"paramData\": {\n" +
                "        \"key\": \"KEY_PLACEHOLDER\"\n" +
                "    },\n" +
                "    \"extAttr\": {\n" +
                "        \"beginTime\": \"2024-07-08 15:59:14\",\n" +
                "        \"mustFinish\": false,\n" +
                "        \"status\": 1\n" +
                "    }\n" +
                "}\n";

        String jsonRequestTemplate = "{\n" +
                "  \"body\": {\n" +
                "    \"type\": \"${type}\",\n" +
                "    \"scene\": \"${scene}\",\n" +
                "    \"receiverAccountData\": ${receiverAccountData},\n" +
                "    \"paramData\": {\n" +
                "      \"key\": \"${paramData.key}\"\n" +
                "    },\n" +
                "    \"extAttr\": {\n" +
                "      \"beginTime\": \"${extAttr.beginTime}\",\n" +
                "      \"mustFinish\": \"${extAttr.mustFinish}\",\n" +
                "      \"status\": \"${extAttr.status}\"\n" +
                "    }\n" +
                "  },\n" +
                "  \"signature\": \"${signature}\"\n" +
                "}\n";

        AssembleUtils jsonUtils = new JsonAssembleUtils();
        String jsonResult = jsonUtils.replaceTemplate(jsonRequestTemplate, request);
        System.out.println("JSON Result:");
        System.out.println(jsonResult);


    }
}
